#include "DTextureManager.h"

DTextureManager::DTextureManager(void) : m_Index(0)
{
}

DTextureManager::~DTextureManager(void)
{
}

int DTextureManager::AddTexture( TCHAR* filePath )
{
	for(int i = 0; i< m_Index; ++i)
	{
		if(_tcscmp(filePath, m_DTextureMap[i]->GetFilePath()) == 0)
			return i;
	}
	DTexture* pDTexture = new DTexture;
	pDTexture->Load(filePath);
	m_DTextureMap[m_Index] = pDTexture;
	++m_Index;
	return m_Index-1;
}

DTexture* DTextureManager::GetTexture( int index )
{
	return m_DTextureMap[index];
}

void DTextureManager::Release()
{
	std::map<int,DTexture*>::iterator iter_del;
	for( iter_del = m_DTextureMap.begin(); iter_del != m_DTextureMap.end(); ++iter_del)
	{
		iter_del->second->Release();	
		delete iter_del->second;
	}
	m_DTextureMap.clear();
}
